package com.itheima.修饰符.状态修饰符.myfinal.final修饰成员变量_04;

/*
        final修饰成员变量! 特点:
            1.被final修饰的成员变量一旦初始化,其值不可变
            2.被final修饰的成员变量只能赋值一次,但是赋值时机有两种:
                2.1可以在定义类时,直接给值,后期该类所有对象该属性值固定不可变(全类所有对象公用同一个值!)
                2.2在定义不给值,在所有构造方法执行结束前对其赋值(一个对象一个值,后期不可变)
 */
public class YellowFamily {
    public YellowFamily(){
        sex = "男";
    }
    public YellowFamily(String sex){
        this.sex = sex;
    }
    final String XING = "黄";
    final String sex;
}
class Demo{
    public static void main(String[] args) {
        YellowFamily y1 = new YellowFamily();
        System.out.println(y1.XING);
        System.out.println(y1.sex);

        YellowFamily y2 = new YellowFamily("女");
        System.out.println(y2.XING);
        System.out.println(y2.sex);
    }
}
